﻿using Shop.RemoteModel.Advert;
using Shop.RemoteModel.Advert.Model;
using Shop.Service.Interface;
using WeDonekRpc.Client;
using WeDonekRpc.Client.Interface;

namespace Shop.Service.RpcEvent
{
    internal class AdvertEvent : IRpcApiService
    {
        private readonly IAdvertService _Service;

        public AdvertEvent (IAdvertService service)
        {
            this._Service = service;
        }
        public void EndAdvert (EndAdvert obj)
        {
            this._Service.End(obj.Id);
        }
        public long AddAdvert (AddAdvert data)
        {
            return this._Service.Add(data.Datum);
        }

        public void DeleteAdvert (DeleteAdvert obj)
        {
            this._Service.Delete(obj.Id);
        }

        public void EnableAdvert (EnableAdvert obj)
        {
            this._Service.Enable(obj.Id);
        }

        public AdvertDto GetAdvert (GetAdvert obj)
        {
            return this._Service.Get(obj.Id);
        }

        public PagingResult<AdvertBase> QueryAdvert (QueryAdvert obj)
        {
            return this._Service.Query(obj.Query, obj.ToBasicPage());
        }

        public bool SetAdvert (SetAdvert obj)
        {
            return this._Service.Set(obj.Id, obj.Datum);
        }

        public void StopAdvert (StopAdvert obj)
        {
            this._Service.Stop(obj.Id);
        }
    }
}
